<?php
$mod='blank';
include("../Core/Common.php");
@header('Content-Type: text/html; charset=UTF-8');
if($islogin_user==1){}else exit("<script language='javascript'>window.location.href='./Social.php';</script>");
$qq=daddslashes($userrow['qq']);
$row=$DB->query("SELECT * FROM `pay_check` WHERE `qq`='{$qq}' limit 1")->fetch();
if($row=='')exit("<script language='javascript'>alert('授权平台不存在该QQ！');history.go(-1);</script>");
if($row['status']==0)exit("<script language='javascript'>alert('此QQ的授权已被封禁！');history.go(-1);</script>");


$authcode=$row['authcode'];
$sign=$row['sign'];
if(!$authcode){exit();}

$file_real=substr($authcode,0,16).'.zip';
$file=ROOT.CACHE_DIR."/{$file_real}";

if($_GET['my']=='installer') {
$file_path=ROOT.PACKAGE_DIR.'/release/';

//安装包
$file_str=file_get_contents(ROOT.PACKAGE_DIR.'/Authcode.php');
$file_str=str_replace('1000000001',$authcode,$file_str);
file_put_contents($file_path.'Core/Authcode.php',$file_str);


$file_name='release_'.$qq.'.zip';

}elseif($_GET['my']=='updater') {
$file_path=ROOT.PACKAGE_DIR.'/update/';

//更新包
$file_str=file_get_contents(ROOT.PACKAGE_DIR.'/Authcode.php');
$file_str=str_replace('1000000001',$authcode,$file_str);
file_put_contents($file_path.'Core/Authcode.php',$file_str);

$file_name='update_'.$qq.'.zip';
}
if(file_exists($file))unlink($file);
$zip = new PclZip($file);
$v_list = $zip->create($file_path ,PCLZIP_OPT_REMOVE_PATH,$file_path);

$file_size=filesize("$file");
header("Content-Description: File Transfer");
header("Content-Type:application/force-download");
header("Content-Length: {$file_size}");
header("Content-Disposition:attachment; filename={$file_name}");
readfile("$file");
?>